package com.web.netty.domain;

import java.io.Serializable;
import java.util.Arrays;

/**
 * @Author: wws
 * describe:
 */

public class DataUp implements Serializable {
    private byte head;//字节头
    private byte[] token;//随机数
    private byte direction;//方向
    private byte[] dataUpPayload;

    public DataUp() {
    }

    public DataUp(byte[] data) {
        this.head = data[0];
        this.token = Arrays.copyOfRange(data, 1, 3);
        this.direction = data[3];
        this.dataUpPayload = Arrays.copyOfRange(data, 4, data.length);
    }

    public DataUp(byte head, byte[] token, byte direction, byte[] dataUpPayload) {
        this.head = head;
        this.token = token;
        this.direction = direction;
        this.dataUpPayload = dataUpPayload;
    }

    public byte getHead() {
        return head;
    }

    public void setHead(byte head) {
        this.head = head;
    }

    public byte[] getToken() {
        return token;
    }

    public void setToken(byte[] token) {
        this.token = token;
    }

    public byte getDirection() {
        return direction;
    }

    public void setDirection(byte direction) {
        this.direction = direction;
    }

    public byte[] getDataUpPayload() {
        return dataUpPayload;
    }

    public void setDataUpPayload(byte[] dataUpPayload) {
        this.dataUpPayload = dataUpPayload;
    }

    @Override
    public String toString() {
        return "DataUp{" +
                "head=" + head +
                ", token=" + Arrays.toString(token) +
                ", direction=" + direction +
                ", dataUpPayload=" + Arrays.toString(dataUpPayload) +
                '}';
    }
}
